package mips.value;

public class VirRegister extends MipsValue {
    // 这个是llvmir中的虚拟寄存器
    private int offset;

    public VirRegister(int offset) {
        this.offset = offset;
    }

    public int getOffset() {
        return offset;
    }

    @Override
    public String toString() {
        // 根据偏移量从栈里取值
        return offset + "($sp)";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof VirRegister) {
            return ((VirRegister) obj).offset == offset;
        }
        return false;
    }
}
